// index.js
// 获取应用实例
const app = getApp()

const app2 = getApp().globalData   
// const imageCdn = 'https://tdesign.gtimg.com/miniprogram/images';
// const swiperList = [
//   `http://homework.1lx.xyz/1.jpg`,
//   `${imageCdn}/swiper2.png`,
//   `${imageCdn}/swiper1.png`,
//   `${imageCdn}/swiper2.png`,
//   `${imageCdn}/swiper1.png`,  
// ];
Page({
  data: {
    current: 1,
    autoplay: true,
    duration: 500,
    interval: 5000,
    // swiperList,
    marquee2: {
      speed: 60,
      loop: -1,
      delay: 0,
    },
    visible: true,
    content: [],
    nowTime: '',
    img1: 'https://img.icons8.com/color/96/000000/checked--v1.png', // 签到
    img2: 'https://img.icons8.com/color/96/000000/ask-question.png', // 请假
    img3: 'https://img.icons8.com/color/96/000000/classroom.png',    // 班级
    list:[
      {name:'高考倒计时0天|龙江工程学子预祝金榜题名！',img:'https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=400&q=80',url:'https://blog.sina.com.cn/s/blog_7e83f8f30102z2rs.html'},
      {name:'这个夏日，让我们去龙江工程一探究“镜”吧',img:'http://mmbiz.qpic.cn/mmbiz_jpg/brQSlexibdx9fvJ9l6tFAp2NYzerKw2r1p7quAt8GDMWAWIS4kozq0Gpc3x4DiaibOtkBuZ3enRuzibsyW9RVZczibw/0?wx_fmt=jpeg',url:'http://www2.hljit.edu.cn:8011/zs/index.asp'},
      {name:'龙江工程版挖呀挖呀挖，等你来挖！',img:'https://images.unsplash.com/photo-1519125323398-675f0ddb6308?auto=format&fit=crop&w=400&q=80',url:'https://www.eol.cn/liuxue/zwhzbxhljgcxyxxjs/index.html'},
      {name:'喜报！我校教师在第三届全国高校教师教学创新大赛（黑龙江赛区）中获得佳绩',img:'https://mmbiz.qpic.cn/mmbiz_jpg/brQSlexibdxib6rYETa965O2TTnWau3kcYxLDTDiaNnb6LOez2uibr1sIp1ABpZXsyYpFoOUQoqrWXFCcR7EvPDCnA/0?wx_fmt=jpeg',url:'https://article.xuexi.cn/articles/index.html?art_id=15579000986546746866&item_id=15579000986546746866&study_style_id=feeds_opaque&pid=&ptype=-1&source=share&share_to=wx_single'},
      {name:'青春的颜色——纪念五四运动104周年',img:'https://images.unsplash.com/photo-1465101046530-73398c7f28ca?auto=format&fit=crop&w=400&q=80',url:'https://www.people.com.cn/'}
    ],
    userInfo:{}
  },
  // 事件处理函数
  bindViewTap() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  // 详情
  toWebView(e){
    wx.navigateTo({
      url: '/pages/index/webview/index?url='+e.currentTarget.dataset.url,
    })
  },
  onLoad() {
    this.getNowDate()
    
  },
  onShow(){
    
    if(wx.getStorageSync('userInfo')){
      this.setData({
        userInfo:wx.getStorageSync('userInfo')
      })
    }
    
  },
  // 签到
  onQiandao(){
    if(wx.getStorageSync('userInfo').user.identity == 1){
      wx.showToast({
        title: '老师无需打卡！',
        icon:'none'
      })
    }else{
      wx.navigateTo({
        url: '/pages/index/qiandao/index/index',
      })
    }
  },
  // 请假
  onQingjia(){
    if(wx.getStorageSync('userInfo').user.identity == 1){
      wx.navigateTo({
        url:'/pages/index/t_qingjia/index'
      })
    }else{
      wx.navigateTo({
        url: '/pages/index/qingjia/index',
      })
    }
    
  },
  // 班级
  onCLass(){
    if(wx.getStorageSync('userInfo').user.identity == 1){
      wx.navigateTo({
        //url: '/pages/index/qclass/index',
        url:'/pages/index/t_class/index'
      })
    }else{
      wx.navigateTo({
        url: '/pages/index/qclass/index',
        //url:'/pages/index/t_class/index'
      })
    }
    
  },
  // 问卷
  onWenjuan(){
    wx.navigateTo({
      url: '/pages/index/wenjuan/index',
    })
    // wx.showToast({
    //   title: '功能暂未开放！',
    //   icon:'none'
    // })
  },
  // 公告
  onGonggao(){
    wx.navigateTo({
      url: '/pages/index/gonggao/index',
    })
  },
  // 格式化时间
  getNowDate: function () {
    var date = new Date();
    var year = date.getFullYear() //年
    var month = date.getMonth() + 1//月
    var day = date.getDate()//日


    var xiaoshi = "";
    if (month < 10) {
      xiaoshi = "0" + month;
    } else {
      xiaoshi = month + "";
    }

    var fenzhong = "";
    if (day < 10) {
      fenzhong = "0" + day;
    } else {
      fenzhong = day + "";
    }
    this.setData({
      nowTime: year + '-' + xiaoshi + '-' + fenzhong 
    })
  },

})
